<?php
require_once ('libraryfiles/config.php');
$content = 'facebook_account_type.php';
require_once TMP_USER_PATH;
if (isset($_SESSION ['username'])) {
    ?>
    <script type="text/javascript">
        window.location = "<?php echo W_ROOT; ?>"
    </script>
    <?php
    exit();
} else {

    if (!empty($_GET ["return_url"])) {
        $return_url = @ $_GET ["return_url"];
    } else {
        $return_url = $CURRENT_URL;
    }
    $success = isset($_GET ['success']) ? $_GET ['success'] : '';

    $config = dirname(__FILE__) . '/hybridauth/config.php';
    include (S_ROOT . "/hybridauth/Hybrid/Auth.php");
    ?>
    <!--Messsage-->
    <?php
    if (isset($_GET ['success']) != "") {
        $message = $_GET ['success'];
    } else {
        $message = '';
    }

    // if we got an error then we display it here
    if ($message) {
        ?>
        <div class="alert alert-success fade in">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <h3 class="alert-heading">
                <!--Well done! You successfully.-->
                <?php echo $lang['SUCCESSSMS']; ?></h3>
            <p style="font-size: 16px;">
            <blink><?php echo @$lang[$message]; ?></blink>
        </p>
        </div>
        <?php
    }
    ?>
    <!--End Message-->
    <!--Messsage-->
    <?php if (!empty($_GET['message'])) { ?>
        <div class="row-fluid">
            <div class="span12">
                <?php
                if (isset($_GET ['message']) != "") {
                    $message = $_GET ['message'];
                } else {
                    $message = '';
                }
                // if we got an error then we display it here
                if ($message) {
                    ?>
                    <div class="alert alert-block fade in">
                        <button type="button" class="close" data-dismiss="alert">&times;</button>
                        <h3 class="alert-heading">
                            <!--Heads up! This alert needs your attention-->
                            <?php echo $lang['HEADE_UP_ALERT']; ?></h3>
                        <p style="font-size: 16px;">
                        <blink><?php echo @$lang[$message]; ?></blink>
                        </p>
                    </div>
                    <?php
                }
                ?> 
            </div>
        </div>
        <!--End Message-->
        <!--Error-->
        <?php
    }
    $CURRENT_URL = W_ROOT;
    if (isset($_GET ['error']) != "") {
        $error = isset($_GET ['error']) ? $_GET ['error'] : '';
        switch ($error) {
            case 1 :
                $message = $lang ['EMAILADDINVALID'];
                break;
            case 2 :
                $message = 'Email Address &amp; Password is Invalid';
                break;
            case 3 :
                $message = $lang ['PLSSELECTTHEACCOUNT'];
                break;
            case 4 :
                $message = "Missing provider application credentials.";
                break;
            case 5 :
                $message = "Authentification failed. The user has canceled the authentication or the provider refused the connection.";
                break;

            default :
                $message = "Unspecified error!";
        }
    } else {
        $message = '';
    }
    ?>

    <!--end Error-->

    <!--test foundation formlogin-->
    <?php if (!empty($_GET['error'])) { ?>
<div class="row-fluid">
	<div class="span12">
		<?php
                $CURRENT_URL = W_ROOT;
                if (isset($_GET ['error'])) {
                    $message = $_GET ['error'];
                    ?>
		<div class="alert alert-block alert-error fade in">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<h3 class="alert-heading">
				<!--Oh snap! You got an error!-->
				<?php echo $lang['SNAB_ERROO']; ?>
			</h3>
			<p style="font-size: 16px;">
				<blink>
					<?php echo @$lang[$message]; ?>
				</blink>
			</p>
		</div>
		<?php
                }
                ?>
	</div>
</div>
<?php } ?>



    <div class="row-fluid">
        <div class="span12">
            <div class="box laster custom">
                <div class="box-heading">
                    <h2><?php echo $lang['LOGINTOURKHMACC']; ?></h2>
                </div>
                <div class="box-content">
                    <div class="product-grid" style="padding: 10px;">					
                        <div class="row-fluid">
                            <?php
                            $hybridauth = new Hybrid_Auth($config);
                            $connected_adapters_list = $hybridauth->getConnectedProviders();
                                include(S_ROOT . '/social/icon-login.php'); ?>
                        </div>					
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
}
?>